from common_1.Ultils import ForumDriver
from selenium.webdriver.common.by import By

class ForumHomepage:
    url=""
    driver=""
    def __init__(self):
        url="http://127.0.0.1:9580/index.html"
        self.driver=ForumDriver.driver
        self.driver.get(url)
    def ForumHomepageTest(self):
        # 检查页面应有的元素
        # 用户信息
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_avatar").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_settings")
        # 帖子板块分类
        self.driver.find_element(By.CSS_SELECTOR,"#navbar-menu > div > div")
        # 帖子发布按钮
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post")
        # 帖子列表
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-body > div > div > div > div > div")
        # 搜索栏
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input")
        # 深/浅主题切换
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-light > svg")
        # 消息通知栏
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_offcanvasEnd > div.offcanvas-header")
        self.driver.find_element(By.CSS_SELECTOR,"#index_div_message")
